package com.heima.test1;

import java.io.IOException;
import java.util.concurrent.ExecutionException;

class A implements Runnable {
    int num = 1;

    @Override
    public void run() {
        synchronized (this) {
            System.out.println(Thread.currentThread().getName() + "通过山洞,他是第" + num + "个");
            num++;
        }
    }
}


public class Demo02 {
    public static void main(String[] args) throws ExecutionException, InterruptedException, IOException {
        A a = new A();
        for (int i = 0; i < 10; i++) {
            new Thread(a).start();
        }
    }
}
